/*
 *  Copyright (C) 2011 Sitem Cartografia SLU
 */
package com.sitem.appsjam.Types;

import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;

import org.json.JSONException;
import org.json.JSONObject;

import android.content.Context;
import android.graphics.drawable.Drawable;

public class Layer {

	public int id = -1;
	public String id_textual_controlcapes = ""; //Les ids de les capes son strings en lloc de ints
	public ArrayList<Punt> nodes = new ArrayList<Punt>();
	public Drawable icon = null;
	public boolean visible = true;
	private String name = null;
	
	public Layer(JSONObject o) throws JSONException, IOException {
		id = o.optInt("id");
		name = o.getString("name");
		String url = o.optString("img", null);
		if (url != null) {
			URL mUrl = new URL(url);
			this.icon = Drawable.createFromStream(mUrl.openStream(), "src");
		}
	}
	public Layer(int id, String name) {
		this.name = name;
		this.id = id;
	}
	public Layer(int id, String name, Drawable mIcon) {
		this.name = name;
		this.id = id;
		this.icon = mIcon;
	}

	public String getName(Context base) {
		return name;
	}

}
